function SpButton(clientName, buttonId, enable, mouseDownCss, mouseUpCss, enableCss, disableCss) {
  var _buttonId = buttonId;
  var _enable = enable;
  var _mouseDownCss = mouseDownCss;
  var _mouseUpCss = mouseUpCss;
  var _enableCss = enableCss;
  var _disableCss = disableCss;
  var _util = Library.WebControl.Util;
  var _instance = this;
  var _onclick = null;
  _globalHashObject.Add(clientName, _instance);
  window[clientName] = _instance;

  function getButton() {
    return _util.GetObjectById(_buttonId);
  };
  this.Call = function(t) {
    if (!_enable) return;
    switch (t) {
      case 1: // Click
        if (_onclick != null) _onclick(_instance, {});
        break;
      case 2: //mouse down
        _util.SetClass(getButton(), _mouseDownCss);
        break;
      case 3: //mouse up
        _util.SetClass(getButton(), _mouseUpCss);
        break;
    }
  };
  this.AddHandler = function(t, f) {
    _onclick = f;
  };
  this.Click = function() {
    _instance.Call(1);
  };

  this.GetText = function() {
    var child = _util.FindFirstChild(_buttonId, "div", "spTextButton", true);
    if (child) return child.innerHTML;
    return "";
  };
  this.SetText = function(t) {
    var child = _util.FindFirstChild(_buttonId, "div", "spTextButton", true);
    if (child) child.innerHTML = t;
  };
  this.GetValue = function() {
    return _instance.GetText();
  };
  this.SetValue = function(t) {
    _instance.SetText(t);
  };
  this.Visible = function() {
    var btn = getButton();
    if (arguments.length > 0) {
      btn.style.display = arguments[0] ? "" : "none";
    }
    return btn.style.display != "none";
  };
  this.Enable = function() {
    if (arguments.length > 0) {
      if (arguments[0]) _enable = true;
      else _enable = false;
      var clzz = _enable ? _enableCss : _disableCss;
      _util.SetClass(getButton(), clzz)
    }
    return _enable;
  };
};
